<?php

namespace App\Listeners;

use App\Models\ApiLog;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class AddApiLogListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        $al=new ApiLog();
        $al->server_id=$event->sid;
        $al->url=$event->url;
        $al->res=$event->res;
        $al->err=$event->err;
        $al->data=json_encode($event->data);
        $al->save();
    }
}
